<template>
  <scroll-view
    v-if="Object.values(data).length"
    scroll-y="true"
    class="content"
  >
    <view class="list-item">
      <view class="item">
        <view class="detail">
          <view>
            <text class="font-bold">公告类型：</text> {{ data.noticeType }}
          </view>
          <view>
            <text class="font-bold">发布人: </text>
            {{ data.creatorName }}</view
          >
          <view>
            <text class="font-bold">发布时间： </text>
            {{ data.createTime }}</view
          >
        </view>
      </view>
    </view>

    <view class="list-item">
      <view class="item">
        <view
          class="text-center font-bold"
          style="width: 80%; margin: auto; font-size: 14px"
        >
          公告标题： {{ data.title }}
        </view>
        <view v-html="data.content"> </view>
      </view>
    </view>
    <uni-section
      v-if="data.attachmentList?.length"
      title="附件信息"
      type="line"
    >
      <uni-list>
        <uni-list-item
          ellipsis="1"
          v-for="(i, z) in attachmentList"
          :key="z"
          :title="i.attachmentName"
        >
          <template v-slot:footer>
            <text
              class="download"
              @click="downloadFile(`${baseUrl}${i?.attachmentPath}`)"
              >查看</text
            >
          </template>
        </uni-list-item>
      </uni-list>
    </uni-section>
  </scroll-view>

  <view v-else class="no-data"> 暂无数据 </view>
</template>
  
  <script>
import request, { baseUrl } from "@/utils/httpInterceptor";
import { downloadFile } from "@/utils/download";
export default {
  data() {
    return {
      id: "",
      data: {},
    };
  },

  computed: {},
  onLoad: function (option) {
    uni.setNavigationBarTitle({
      title: option?.noticeType || "详情",
    });
    this.id = option.id;
    this.getDetail();
  },

  methods: {
    downloadFile,

    async getDetail() {
      const res = await request({
        url: `/inform/notice/${this.id}`,
        method: "GET",
      });

      this.data = res.data || {};
    },
  },
};
</script>
  
  <style lang="scss" scoped>
.action-number {
  padding: 0 10px;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  position: fixed;
  bottom: 45px;
  width: 100%;
  border-top: 1px solid #eee;
  height: 35px;
  align-items: center;
}
</style>
  